Skip to content

Add rules for stdlib, rustls, and stdio#183

Open
lucic71 wants to merge 3 commits into
Cpp2Rust:masterfrom
lucic71:rustls
Open

Add rules for stdlib, rustls, and stdio#183
lucic71 wants to merge 3 commits into
Cpp2Rust:masterfrom
lucic71:rustls

Conversation

@lucic71

@lucic71 lucic71 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

I also had to add support in Mapper for rules of typedef'ed scalars.

For exmaple:

typedef int rustls_io_result;
int -> ::rustls_ffi::rustls_io_result

Would clash with the already-existing rule of int because ToString strips the typedef and returns int instead of rustls_io_result. GetNameOfScalarTypedef returns rustls_io_result and the mapping becomes:

typedef int rustls_io_result;
rustls_io_result -> ::rustls_ffi::rustls_io_result

Initially I wanted to modify ToString to not strip the typedef, but that's a bigger change than I expected because it affects typedefs as size_t, uint32_t, etc.

Comment thread rules/rustls/rustls.h
@@ -0,0 +1,2869 @@
#ifndef RUSTLS_H
#define RUSTLS_H

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this file needed and what's the origin?

@lucic71 lucic71 Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed to get the C symbols that we translate to rust, similar to brotli: https://github.com/Cpp2Rust/cpp2rust/tree/master/rules/brotli/brotli

This is the origin: https://github.com/rustls/rustls-ffi/blob/main/librustls/src/rustls.h

I installed the deb package (https://github.com/rustls/rustls-ffi/releases/tag/v0.15.3) for rustls-ffi on my system and copied /usr/include/rustls.h into rules/rustls/rustls.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants